package ControllerSrevlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import MYJDBC.jdbc;

/**
 * Servlet implementation class User_GzTest 用户关注
 */
@WebServlet("/User_GzTest")
public class User_GzTest extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public User_GzTest() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		request.setCharacterEncoding("UTF-8");
		String userid = request.getParameter("userid");
		String userfid = request.getParameter("userfid");
		int id = Integer.parseInt(userid);
		int fid = Integer.parseInt(userfid);
		
		jdbc jc = new jdbc();
		try {
			jc.SqlUpdate("insert into user_friend (user_id,user_myfid) value ("+id+","+fid+");");
			jc.SqlUpdate("insert into user_friend (user_id,user_myfid) value ("+fid+","+id+");");
			jc.UpdateClose();
			response.sendRedirect("BlueVideoUserMsg");
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
